Let $a,$ $b,$ $c$ be the roots of $x^3 + px + q = 0.$  Express
\[\begin{vmatrix} 1 + a & 1 & 1 \\ 1 & 1 + b & 1 \\ 1 & 1 & 1 + c \end{vmatrix}\]in terms of $p$ and $q.$
Answer: We can expand the determinant as follows:
\begin{align*}
\begin{vmatrix} 1 + a & 1 & 1 \\ 1 & 1 + b & 1 \\ 1 & 1 & 1 + c \end{vmatrix} &= (1 + a) \begin{vmatrix} 1 + b & 1 \\ 1 & 1 + c \end{vmatrix} - \begin{vmatrix} 1 & 1 \\ 1 & 1 + c \end{vmatrix} + \begin{vmatrix} 1 & 1 + b \\ 1 & 1 \end{vmatrix} \\
&= (1 + a)((1 + b)(1 + c) - 1) - ((1)(1 + c) - 1) + (1 - (1 + b)) \\
&= abc + ab + ac + bc.
\end{align*}By Vieta's formulas, $ab + ac + bc = p$ and $abc = -q,$ so
\[abc + ab + ac + bc = \boxed{p - q}.\]